CREATE TABLE [dbo].[DnnProduct_Modules]
(
[ModuleID] [int] NOT NULL IDENTITY(0, 1),
[ModuleDefID] [int] NOT NULL,
[AllTabs] [bit] NOT NULL CONSTRAINT [DF_DnnProduct_Modules_AllTabs] DEFAULT ((0)),
[IsDeleted] [bit] NOT NULL CONSTRAINT [DF_DnnProduct_Modules_IsDeleted] DEFAULT ((0)),
[InheritViewPermissions] [bit] NULL,
[StartDate] [datetime] NULL,
[EndDate] [datetime] NULL,
[PortalID] [int] NULL,
[CreatedByUserID] [int] NULL,
[CreatedOnDate] [datetime] NULL CONSTRAINT [DF_DnnProduct_Modules_CreatedOnDate] DEFAULT (getdate()),
[LastModifiedByUserID] [int] NULL,
[LastModifiedOnDate] [datetime] NULL CONSTRAINT [DF_DnnProduct_Modules_LastModifiedOnDate] DEFAULT (getdate()),
[ContentItemID] [int] NULL,
[LastContentModifiedOnDate] [datetime] NOT NULL CONSTRAINT [DF_DnnProduct_Modules_LastContentModifiedOnDate] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[DnnProduct_Modules] ADD CONSTRAINT [PK_DnnProduct_Modules] PRIMARY KEY NONCLUSTERED  ([ModuleID]) WITH (FILLFACTOR=85) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_DnnProduct_Modules] ON [dbo].[DnnProduct_Modules] ([ModuleDefID]) WITH (FILLFACTOR=85) ON [PRIMARY]
GO
ALTER TABLE [dbo].[DnnProduct_Modules] ADD CONSTRAINT [FK_DnnProduct_Modules_DnnProduct_ContentItems] FOREIGN KEY ([ContentItemID]) REFERENCES [dbo].[DnnProduct_ContentItems] ([ContentItemID])
GO
ALTER TABLE [dbo].[DnnProduct_Modules] ADD CONSTRAINT [FK_DnnProduct_Modules_DnnProduct_ModuleDefinitions] FOREIGN KEY ([ModuleDefID]) REFERENCES [dbo].[DnnProduct_ModuleDefinitions] ([ModuleDefID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[DnnProduct_Modules] WITH NOCHECK ADD CONSTRAINT [FK_DnnProduct_Modules_DnnProduct_Portals] FOREIGN KEY ([PortalID]) REFERENCES [dbo].[DnnProduct_Portals] ([PortalID]) NOT FOR REPLICATION
GO
